package com.itzhoun.validate;

import cn.hutool.core.util.IdcardUtil;
import com.itzhoun.annotation.IdCard;
import org.springframework.context.annotation.Configuration;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 这里就是实现自定义注解的方法
 * @author 周楠
 * @Date 2022/06/29/上午 9:13
 */
public class IdCardValidator implements ConstraintValidator<IdCard,Object> {

    @Override
    public boolean isValid(Object o, ConstraintValidatorContext constraintValidatorContext) {
        return IdcardUtil.isValidCard(o.toString());
    }

    @Override
    public void initialize(IdCard constraintAnnotation) {

    }
}
